import 'package:flutter/material.dart';

import '../route/RoutePath.dart';

class WidgetPage extends StatelessWidget {
  const WidgetPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('组件'),
        centerTitle: true,
        backgroundColor: Colors.white,
      ),
      body: ListView(
        children: [
          Wrap(
            spacing: 8.0,
            runSpacing: 4.0,
            alignment: WrapAlignment.start,
            children: RoutePath.routeMap.keys.map((key) {
              return Chip(
                avatar: CircleAvatar(
                  backgroundColor: Colors.blue,
                  child: Text(key[0]),
                ),
                label: TextButton(
                  onPressed: () {
                    Navigator.pushNamed(
                        context, key.substring(0, key.indexOf(' - ')));
                  },
                  child: Text(key.substring(key.indexOf(' - ') + 3)),
                ),
              );
            }).toList(),
          )
        ],
      ),
      backgroundColor: Colors.grey,
    );
  }
}
